YUI.add("participantsListModel", function(Y) {
    var log = Y.log,
    ParticipantEvent = Y.ParticipantEvent;
    /* ParticipantsListModel constructor */
    var ParticipantsListModel = function(config) {
        ParticipantsListModel.superclass.constructor.apply(this, arguments);
    } 
    ParticipantsListModel.NAME = "participantsListModel";
  
 
    /* Default ParticipantsListModel Attributes */
    ParticipantsListModel.ATTRS = {
        "list" : { 
	         value: new Array()
	      }
    };
 
    /* Extend the base Widget class */
    Y.extend(ParticipantsListModel, Y.Base, {
 		
        /*
         * Initialization Code: Sets up privately used state
         * properties, and publishes the events ParticipantsListModel introduces
         */
        initializer : function(config) { 
 			this._loadData();
        },
 
        /*
         * Destruction Code: Clears event handles, timers,
         * and current trigger information
         */
        destructor : function() {
            
        },
 
        
        _loadData : function() {
        	//var myDataSource = new Y.DataSource.IO({source:"http://127.0.0.1/ChatWidget/assets/temp.xml"});  
        	var myDataSource = new Y.DataSource.IO({source:"http://127.0.0.1/ChatWidget/assets/buddylist.xml"});  
        	myDataSource.plug({fn: Y.Plugin.DataSourceXMLSchema, cfg: {
    			schema: Y.ParticipantModel.schema
			}});
			var that = this;
			 myCallbackJSON = {
            	success: function(e){
                	//log(Y.dump(e.response["results"] )); 
                	var list = e.response["results"]; 
                	var participantsList = that.get("list");
                	var len = list.length;
                	for(var i=0; i < len; i++)
                	{
                		var model = list[i];
                		var participantModel = new Y.ParticipantModel({model:model});
                		participantsList.push(participantModel);
                	}
                	
               
                	//fire done event
                	Y.fire(ParticipantEvent.ListModel.ListLoaded , that.get('list'), that);
            	},
            	failure: function(e){
                	alert("CAN NOT GET Participants List DATA");
            	}
        	};
  
        	myDataSource.sendRequest(null, myCallbackJSON);
        }
  
    }); 
 
	Y.ParticipantsListModel = ParticipantsListModel; 
//});
} , 0.1  );